package demo524;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.Scanner;

public class Delete {
    public static void main(String[] args) throws ClassNotFoundException, SQLException{
        Connection connection = SqlConnection.getCon();
        Scanner  scanner = new Scanner(System.in);
        System.out.println("请输入用户的id");
        int id = scanner.nextInt();
        String sql = "delete from users where id=?";
        PreparedStatement preparedStatement = connection.prepareStatement(sql);
        preparedStatement.setInt(1,id);
        int i = preparedStatement.executeUpdate();
        if (i>0){
            System.out.println("删除成功");
        }
        else {
            System.out.println("删除失败");
        }
    }
}
